package com.hua.mapper;

import com.hua.pojo.Food;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hua.utils.CommentDetailDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author hua
 * @since 2023-12-24
 */

public interface FoodMapper extends BaseMapper<Food> {

    //<!--检索的api,通过输入饭堂名称进行检索    -->
    List<Food> selectFoodByCanteenName(@Param("data") String data);

    //随机生成菜品，不按照标签分组的
    @Select("SELECT * FROM food ORDER BY RAND() LIMIT 1")
    Food getRandomFood();


    //按照tabs选择，再从结果集随机生成菜品
    @Select("SELECT * FROM food WHERE tags LIKE CONCAT('%', #{tags}, '%') ORDER BY RAND() LIMIT 1")
    Food getRandomFoodWithTabs(@Param("tags") String tags);






}
